package com.mall.malladminbackend.controller;

import com.mall.malladminbackend.dto.SpecValueDto;
import com.mall.malladminbackend.model.R;
import com.mall.malladminbackend.service.SpecValueService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 作者：tk
 * 时间：2022/8/16 10:00
 * 描述：永无Bug!!!
 */
@RestController
@RequestMapping("/specValue")
@AllArgsConstructor
public class SpecValueController {
    private SpecValueService specValueService;
    @GetMapping("/{id}")
    public R getSpecValues(@PathVariable Integer id,
                           @RequestParam(defaultValue = "1") Integer pageNum,
                           @RequestParam(defaultValue = "5") Integer pageSize){
        return specValueService.selectSpecValue(id,pageNum,pageSize);
    }
    @PostMapping("/insert")
    public R insertSpecValue(@RequestBody SpecValueDto specValueDto) throws Exception {
        return specValueService.insertSpecValue(specValueDto);
    }
    @PutMapping("/update")
    public R updateSpecValue(@RequestBody SpecValueDto specValueDto) throws Exception {
        return specValueService.updateSpecValue(specValueDto);
    }
    @GetMapping("/select/{id}")
    public R selectSpecValuesById(@PathVariable Integer id){
        return specValueService.selectSpecValueById(id);
    }
    @DeleteMapping("/{id}")
    public R delSpecValuesById(@PathVariable Integer id){
        return specValueService.deleteSpecValueById(id);
    }
}
